*** add location here
cd ... 

log using "mainresults.txt", replace

use "prepared_data.dta", clear


keep if inpartyincluded==1
drop if party==idvotecat
drop if party==1&treat3==3 // drop ÖVP evaluation from SPÖ-FPÖ treatment
drop if party==2&treat3==2 // drop SPÖ evaluation from ÖVP-FPÖ treatment
drop if party==3&treat3==1 // drop FPÖ evaluation from SPÖ-ÖVP treatment

*** FIGURE 2
local controls " responseorder"

regress partylike i.treat_stack_v2 i.indic `controls', cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_like
regress partylike i.treat_stack_v2##i.indic  `controls', cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m1_like
regress partylike i.treat_stack_v2##i.indic    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_v2) post
estimates store m2_like
regress partylike i.treat_stack_v2##i.indic    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_v2) post
estimates store m3_like

regress partysocdist i.treat_stack_v2 i.indic   `controls', cluster(U0) 
margins, dydx(treat_stack_v2) post
estimates store m0_socdist
regress partysocdist i.treat_stack_v2##i.indic  `controls', cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m1_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_v2) post
estimates store m2_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_v2) post
estimates store m3_socdist

regress partylike_index i.treat_stack_v2 i.indic    `controls', cluster(U0) 
margins, dydx(treat_stack_v2) post
estimates store m0
sum partylike_index if e(sample)
regress partylike_index i.treat_stack_v2##i.indic    `controls', cluster(U0) 
margins if party==1, dydx(treat_stack_v2) post
estimates store m1
regress partylike_index i.treat_stack_v2##i.indic    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_v2) post
estimates store m2
regress partylike_index i.treat_stack_v2##i.indic    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_v2) post
estimates store m3

sum partylike_index if e(sample)

 coefplot m0 m0_like m0_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.75 "Index" 1 "Like-Dislike" 1.25 "Social Distance") yscale(range(0.7 1.3)) ///
 scheme(plotplain) title("Overall effect") saving(overall.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
 
esttab m0 m0_like m0_socdist using "Fig2_left.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Figure 2, left panel)\label{Fig2left}) replace
 
  coefplot m1 m1_like m1_socdist m2 m2_like m2_socdist m3 m3_like m3_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
 yline(1.15, lpattern(dash) lcolor(black) ) ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.6 "Index" 0.7 "Like-Dislike" 0.8 "Social Distance"  ///
 0.9 "Index" 1 "Like-Dislike" 1.1 "Social Distance" ///
 1.2 "Index" 1.3 "Like-Dislike" 1.4 "Social Distance") yscale(range(0.5 1.5))  ///
 text(0.7 -1.3 "ÖVP") text(1 -1.3 "SPÖ") text(1.3 -1.3 "FPÖ") ///
 scheme(plotplain) title("Effect by coalition partner") saving(parties.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
 
esttab m1 m1_like m1_socdist using "Fig2_right.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Figure 2, right panel)\label{Fig2right}) replace
 
 graph combine overall.gph parties.gph, scheme(plotplain)

 graph export "Figure2.png", replace
 
 erase overall.gph
  erase parties.gph

*** END CODE FOR FIGURE 2

  *** TABLE G.1
local controls " responseorder"
  regress partylike i.treat_stack_v2 i.indic `controls', cluster(U0)
estimates store m0_like
regress partylike i.treat_stack_v2##i.indic  `controls', cluster(U0)
estimates store m1_like
regress partylike i.treat_stack_v2##i.indic    `controls', cluster(U0) 
estimates store m2_like
regress partylike i.treat_stack_v2##i.indic    `controls', cluster(U0) 
estimates store m3_like

regress partysocdist i.treat_stack_v2 i.indic   `controls', cluster(U0) 
estimates store m0_socdist
regress partysocdist i.treat_stack_v2##i.indic  `controls', cluster(U0)
estimates store m1_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls', cluster(U0) 
estimates store m2_socdist
regress partysocdist i.treat_stack_v2##i.indic    `controls', cluster(U0) 
estimates store m3_socdist

regress partylike_index i.treat_stack_v2 i.indic    `controls', cluster(U0) 
estimates store m0
regress partylike_index i.treat_stack_v2##i.indic    `controls', cluster(U0) 
estimates store m1
regress partylike_index i.treat_stack_v2##i.indic    `controls', cluster(U0) 
estimates store m2
regress partylike_index i.treat_stack_v2##i.indic    `controls', cluster(U0) 
estimates store m3
  
 
esttab m0 m0_like m0_socdist using "AppendixTableG1.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Figure 2, left panel)\label{Fig2left}) replace

esttab m1 m1_like m1_socdist using "AppendixTableG2.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Figure 2, right panel)\label{Fig2right}) replace 
  
 
 
 *** END CODE TABLE OF RESULTS FOR FIGURE 2
  
  
 
 ** CODE FOR  RIGHT PANEL FIGURE 3
 
 local controls "responseorder"

regress partylike i.treat_stack_pers i.indic `controls', cluster(U0)
margins, dydx(treat_stack_pers) post
estimates store m0_like
regress partylike i.treat_stack_pers##i.indic  `controls', cluster(U0)
margins if party==1, dydx(treat_stack_pers) post
estimates store m1_like
regress partylike i.treat_stack_pers##i.indic    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_pers) post
estimates store m2_like
regress partylike i.treat_stack_pers##i.indic    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_pers) post
estimates store m3_like

regress partysocdist i.treat_stack_pers i.indic   `controls', cluster(U0) 
margins, dydx(treat_stack_pers) post
estimates store m0_socdist
regress partysocdist i.treat_stack_pers##i.indic  `controls', cluster(U0)
margins if party==1, dydx(treat_stack_pers) post
estimates store m1_socdist
regress partysocdist i.treat_stack_pers##i.indic    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_pers) post
estimates store m2_socdist
regress partysocdist i.treat_stack_pers##i.indic    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_pers) post
estimates store m3_socdist

regress partylike_index i.treat_stack_pers i.indic    `controls', cluster(U0) 
margins, dydx(treat_stack_pers) post
estimates store m0
sum partylike_index if e(sample)
regress partylike_index i.treat_stack_pers##i.indic    `controls', cluster(U0) 
margins if party==1, dydx(treat_stack_pers) post
estimates store m1
regress partylike_index i.treat_stack_pers##i.indic    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_pers) post
estimates store m2
regress partylike_index i.treat_stack_pers##i.indic    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_pers) post
estimates store m3


 coefplot m0 m0_like m0_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(1.5, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.75 "Index" 1 "Like-Dislike" 1.25 "Social Distance" ///
 1.75 "Index" 2 "Like-Dislike" 2.25 "Social Distance")  ///
 text(1 -.9 "Not personal", orientation(vert)) ///
 text(2 -.9 "Personal", orientation(vert)) ///
 scheme(plotplain) title("Effect by Personal Relations") saving(overall.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
  coefplot m1 m1_like m1_socdist , ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
 yline(1.15, lpattern(dash) lcolor(black) ) ///
  yline(1.85, lpattern(dash) lcolor(black) )  ///
 yline(2.15, lpattern(dash) lcolor(black) ) ///
  yline(1.5, lpattern(solid) lcolor(black) ) ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.6 "Index" 0.7 "Like-Dislike" 0.8 "Social Distance"  ///
 0.9 "Index" 1 "Like-Dislike" 1.1 "Social Distance" ///
 1.2 "Index" 1.3 "Like-Dislike" 1.4 "Social Distance" ///
 1.6 "Index" 1.7 "Like-Dislike" 1.8 "Social Distance"  ///
 1.9 "Index" 2 "Like-Dislike" 2.1 "Social Distance" ///
 2.2 "Index" 2.3 "Like-Dislike" 2.4 "Social Distance") yscale(range(0.5 1.5))  ///
 text(0.7 -1.5 "ÖVP") text(1 -1.5 "SPÖ") text(1.3 -1.5 "FPÖ") ///
  text(1.7 -1.5 "ÖVP") text(2 -1.5 "SPÖ") text(2.3 -1.5 "FPÖ") ///
 scheme(plotplain) title("Effect by coalition partner") /// 
 ytitle("  Personal                      Not Personal") saving(parties.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 

 graph export "AppendixFigureK1.png", replace
 
  
  *** CODE FOR LEFT PANEL FIGURE 3
  tab indic, gen(indicat)


local controls "indicat2 indicat3 indicat4 indicat5 indicat6 responseorder"


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345)  
matrix r1= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partylike_index treat_stack_v2  partyconv  `controls') , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r1= r1, r(delta0lo), r(delta0hi) 


medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls') , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r2= r(delta0), r(delta0lo), r(delta0hi) 
medeff (regress partyconv treat_stack_v2 `controls') (regress partylike treat_stack_v2  partyconv  `controls') , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r2= r2, r(delta0lo), r(delta0hi) 



medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) 
matrix r3= r(delta0), r(delta0lo), r(delta0hi) 

medeff (regress partyconv treat_stack_v2 `controls') (regress partysocdist treat_stack_v2  partyconv  `controls') , vce(cl U0) mediate(partyconv) treat(treat_stack_v2) sims(2000) seed(12345) level(90) 
matrix r3= r3, r(delta0lo), r(delta0hi) 

 


matrix r=r1\r2\r3
svmat r
gen index=_n if _n<=3
graph twoway (scatter  index r1 if index<4, msymbol(S) msize(medium) mcolor(black)) (rcap  r2 r3 index  if index<4, horizontal lcolor(gs6) lwidth(thin)) (rcap  r4 r5 index  if index<4, horizontal lcolor(black) lwidth(medthick)), scheme(plotplain) ///
legend(off) ytitle("Effect of coalition signals mediated by distance") ylabel(1 "Index" 2 "Like-Dislike" 3 "Social Distance") yscale(reverse) ///
xline(0, lcolor(red) lpattern(dot))  xscale(range(-.2 .15)) xlabel(-.2(.05).2) ///
yline(1.5, lpattern(dash) lwidth( medthick )) ///
yscale(range(0.5 3.5)) title("Mediation by LR distance") xtitle(ACME, size(small)) saving(mediation.gph, replace)
 ///yline(5.5, lpattern(dot)) 
/// title("ACME from mediation analyses") 
//note("Note:Figure shows average conditional mediated effect of coalition signals "" on affective distance via reduced left-right distance; 95% confidence intervals shown", size(vsmall))

 
 graph combine mediation.gph overall.gph, scheme(plotplain)

 graph export "Figure3.png", replace

 
 *** CODE FOR APPENDIX TABLE  G4
 local controls "responseorder"

 regress partylike i.treat_stack_pers i.indic `controls', cluster(U0)
estimates store m0_like
regress partylike i.treat_stack_pers##i.indic  `controls', cluster(U0)
estimates store m1_like
regress partylike i.treat_stack_pers##i.indic    `controls', cluster(U0) 
estimates store m2_like
regress partylike i.treat_stack_pers##i.indic    `controls', cluster(U0) 
estimates store m3_like

regress partysocdist i.treat_stack_pers i.indic   `controls', cluster(U0) 
estimates store m0_socdist
regress partysocdist i.treat_stack_pers##i.indic  `controls', cluster(U0)
estimates store m1_socdist
regress partysocdist i.treat_stack_pers##i.indic    `controls', cluster(U0) 
estimates store m2_socdist
regress partysocdist i.treat_stack_pers##i.indic    `controls', cluster(U0) 
estimates store m3_socdist

regress partylike_index i.treat_stack_pers i.indic    `controls', cluster(U0) 
estimates store m0
regress partylike_index i.treat_stack_pers##i.indic    `controls', cluster(U0) 
estimates store m1
regress partylike_index i.treat_stack_pers##i.indic    `controls', cluster(U0) 
estimates store m2
regress partylike_index i.treat_stack_pers##i.indic    `controls', cluster(U0) 
estimates store m3
 
   
 
esttab m0 m0_like m0_socdist using "AppendixTableG4.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Figure 2, left panel)\label{Fig2left}) replace
 
 
*********************************
*** CODE FOR FIGURE 4
cd "C:\Users\marku\Dropbox\AP Katrin Markus\replication"

use "prepared_data.dta", clear

gen onlyoutparties=1 if treat3==0|idvotecat==4|idvotecat==5|inpartyincluded==0
replace onlyoutparties=0 if onlyoutparties!=1
drop if party==idvotecat
keep if onlyoutparties==1


local controls " responseorder"

regress partylike i.treat_stack_v2 i.indic_outparty `controls', cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_like
by U0, sort: gen nvals = _n  if e(sample)&treat_stack_v2==0
 by U0, sort: replace nvals = nvals[_N]  if e(sample)&treat_stack_v2==0
 tab nvals
 drop nvals
regress partylike i.treat_stack_v2##i.indic_outparty  `controls', cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m1_like
regress partylike i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_v2) post
estimates store m2_like
regress partylike i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_v2) post
estimates store m3_like

regress partysocdist i.treat_stack_v2 i.indic_outparty   `controls', cluster(U0) 
margins, dydx(treat_stack_v2) post
estimates store m0_socdist
regress partysocdist i.treat_stack_v2##i.indic_outparty  `controls', cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m1_socdist
regress partysocdist i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_v2) post
estimates store m2_socdist
regress partysocdist i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_v2) post
estimates store m3_socdist

regress partylike_index i.treat_stack_v2 i.indic_outparty    `controls', cluster(U0) 
margins, dydx(treat_stack_v2) post
estimates store m0
sum partylike_index if e(sample)
regress partylike_index i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
margins if party==1, dydx(treat_stack_v2) post
estimates store m1
regress partylike_index i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
margins if party==2, dydx(treat_stack_v2) post
estimates store m2
regress partylike_index i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
margins if party==3, dydx(treat_stack_v2) post
estimates store m3



 coefplot m0 m0_like m0_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.75 "Index" 1 "Like-Dislike" 1.25 "Social Distance") yscale(range(0.7 1.3)) ///
 scheme(plotplain) title("Overall effect") saving(overall.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
  coefplot m1 m1_like m1_socdist m2 m2_like m2_socdist m3 m3_like m3_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(0.85, lpattern(dash) lcolor(black) )  ///
 yline(1.15, lpattern(dash) lcolor(black) ) ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.6 "Index" 0.7 "Like-Dislike" 0.8 "Social Distance"  ///
 0.9 "Index" 1 "Like-Dislike" 1.1 "Social Distance" ///
 1.2 "Index" 1.3 "Like-Dislike" 1.4 "Social Distance") yscale(range(0.5 1.5))  ///
 text(0.7 -.8 "ÖVP") text(1 -.8 "SPÖ") text(1.3 -.8 "FPÖ") ///
 scheme(plotplain) title("Effect by coalition partner") saving(parties.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 
 
 graph combine overall.gph parties.gph, scheme(plotplain)

 graph export "Figure4.png", replace

 *** CODE FOR APPENDIX TABLE G5
local controls " responseorder"
regress partylike i.treat_stack_v2 i.indic_outparty `controls', cluster(U0)
estimates store m0_like
regress partylike i.treat_stack_v2##i.indic_outparty  `controls', cluster(U0)
estimates store m1_like
regress partylike i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
estimates store m2_like
regress partylike i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
estimates store m3_like

regress partysocdist i.treat_stack_v2 i.indic_outparty   `controls', cluster(U0) 
estimates store m0_socdist
regress partysocdist i.treat_stack_v2##i.indic_outparty  `controls', cluster(U0)
estimates store m1_socdist
regress partysocdist i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
estimates store m2_socdist
regress partysocdist i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
estimates store m3_socdist

regress partylike_index i.treat_stack_v2 i.indic_outparty    `controls', cluster(U0) 
estimates store m0
regress partylike_index i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
estimates store m1
regress partylike_index i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
estimates store m2
regress partylike_index i.treat_stack_v2##i.indic_outparty    `controls', cluster(U0) 
estimates store m3

 
esttab m0 m0_like m0_socdist using "AppendixTableG5.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Figure 4, left panel)\label{Fig4left}) replace

esttab m1 m1_like m1_socdist using "AppendixTableG6.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Figure 4, right panel)\label{Fig4right}) replace 
  
 
 
 
 *** CODE FOR FIGURE 6

local controls "responseorder"

regress partylike_index i.treat_stack_v2  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
by U0, sort: gen nvals = _n  if e(sample)&treat_stack_v2==0
 by U0, sort: replace nvals = nvals[_N]  if e(sample)&treat_stack_v2==0
 tab nvals
 drop nvals
margins, dydx(treat_stack_v2) post
estimates store m0
sum partylike_index if e(sample)
regress partylike i.treat_stack_v2   `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_like
sum partylike_index if e(sample)
regress partysocdist i.treat_stack_v2  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m0_socdist
sum partylike_index if e(sample)

regress partylike_index i.treat_stack_v2 i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m1
sum partylike_index if e(sample)
regress partylike i.treat_stack_v2 i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m1_like
sum partylike_index if e(sample)
regress partysocdist i.treat_stack_v2 i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m1_socdist
sum partylike_index if e(sample)

coefplot m0 m0_like m0_socdist m1 m1_like m1_socdist , ///
xline(0, lcolor(red) lpattern(dot)) yline(1, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) /// title("Effect of coalition signals on affective distance" "(outparties only in vignette, subsample: Green, Neos + LR<=6)") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>") ///
ylabel(0.64 "Index" .78 "Like-Dislike" 0.93 "Social Distance" ///
 1.07 "Index" 1.22 "Like-Dislike" 1.36 "Social Distance")  ///
 text(0.8 -1.3 "SPÖ", orientation(vert)) ///
 text(1.2 -1.3 "Outparties", orientation(vert)) ///
 xscale(range(-1.5 1.5)) ///
 ///note("Note: 95% and 90% CIs shown", size(vsmall)) 
 scheme(plotplain)

 graph export "Figure6.png", replace

 *** Appendix table G8 
 local controls "responseorder"

regress partylike_index i.treat_stack_v2  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m0
regress partylike i.treat_stack_v2   `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m0_like
regress partysocdist i.treat_stack_v2  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m0_socdist

regress partylike_index i.treat_stack_v2 i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m1
regress partylike i.treat_stack_v2 i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m1_like
regress partysocdist i.treat_stack_v2 i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m1_socdist
 
  
esttab m0 m0_like m0_socdist m1 m1_like m1_socdist using "AppendixTableG8.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Figure 6)\label{Fig6}) replace
 
 
 
 *** APPENDIX FIGURE O1
 
local controls " responseorder"

 regress partylike_index i.treat3   `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat3) post
estimates store m0
sum partylike_index if e(sample)
regress partylike i.treat3  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat3) post
estimates store m0_like
sum partylike_index if e(sample)
regress partysocdist i.treat3   `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party==2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat3) post
estimates store m0_socdist


 coefplot m0 m0_like m0_socdist, ///
xline(0, lcolor(red) lpattern(dot)) yline(1.5, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) ///title("Effect of coalition signals on affective distance") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  xscale(range(-.65 1)) ///
xtitle("<<< less affective distance || more affective distance >>>", size(small)) ///
 ylabel(0.75 "Index" 1 "Like-Dislike" 1.25 "Social Distance" ///
1.75 "Index" 2 "Like-Dislike" 2.25 "Social Distance" ) yscale(range(0.7 1.3)) ///
 text(1 -.55 "with ÖVP") ///
 text(2 -.55 "with FPÖ") ///
 scheme(plotplain) title("Effect on SPÖ affect of SPÖ coalition") saving(overall.gph, replace) // note("Note: 95% and 90% CIs shown", size(vsmall)) 

 graph export "AppendixFigureO1.png", replace


regress partylike_index i.treat_stack_v2##i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m2a
regress partylike i.treat_stack_v2##i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m2a_like
regress partysocdist i.treat_stack_v2##i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m2a_socdist
regress partylike_index i.treat_stack_v2##i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m2b
regress partylike i.treat_stack_v2##i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m2b_like
regress partysocdist i.treat_stack_v2##i.party  `controls' if (idvotecat==4|lrself<=4)&treat3!=2&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m2b_socdist
sum partylike_index if e(sample)


coefplot m2a m2a_like m2a_socdist m2b m2b_like m2b_socdist , ///
xline(0, lcolor(red) lpattern(dot)) yline(1, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) ///title("Effect of coalition signals on affective distance" "(outparties only in vignette, subsample: Green, Neos + LR<=6)") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>") ///
ylabel(0.64 "Index" .78 "Like-Dislike" 0.93 "Social Distance" ///
 1.07 "Index" 1.22 "Like-Dislike" 1.36 "Social Distance")  ///
 text(0.8 -1.3 "ÖVP", orientation(vert)) ///
 text(1.2 -1.3 "FPÖ", orientation(vert)) ///
 xscale(range(-1.5 1.5)) ///
 ///note("Note: 95% and 90% CIs shown", size(vsmall)) 
 scheme(plotplain)

 graph export "AppendixFigureO2.png", replace


  *** CODE FOR FIGURE 5
local controls " responseorder"

regress partylike_index i.treat_stack_v2 i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins , dydx(treat_stack_v2) post
estimates store m1
regress partylike i.treat_stack_v2 i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins, dydx(treat_stack_v2) post
estimates store m1_like
regress partysocdist i.treat_stack_v2 i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins , dydx(treat_stack_v2) post
estimates store m1_socdist
 
regress partylike_index i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m2a
regress partylike i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m2a_like
regress partysocdist i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==1, dydx(treat_stack_v2) post
estimates store m2a_socdist
regress partylike_index i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m2b
regress partylike i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m2b_like
regress partysocdist i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
margins if party==3, dydx(treat_stack_v2) post
estimates store m2b_socdist
sum partylike_index if e(sample)


coefplot m1 m1_like m1_socdist m2a m2a_like m2a_socdist m2b m2b_like m2b_socdist , ///
xline(0, lcolor(red) lpattern(dot)) yline(.85, lpattern(dash) lcolor(black) )  ///
yline(1.15, lpattern(dash) lcolor(black) )  ///
mcolor(black) ciopts(color(gs6 black )) ///title("Effect of coalition signals on affective distance" "(outparties only in vignette, subsample: Green, Neos + LR<=6)") 
levels(95 90) legend(off) msymbol(O) mcolor(black)  ///
xtitle("<<< less affective distance || more affective distance >>>") ///
ylabel(0.6 "Index" .7 "Like-Dislike" 0.8 "Social Distance" ///
0.9 "Index" 1 "Like-Dislike" 1.1 "Social Distance" ///
1.2 "Index" 1.3 "Like-Dislike" 1.4 "Social Distance"  )  ///
text(0.7 -1.3 "Overall", orientation(vert)) ///
 text(1 -1.3 "ÖVP", orientation(vert)) ///
 text(1.3 -1.3 "FPÖ", orientation(vert)) ///
 xscale(range(-1.25 1)) xlabel(-1.5(.5)1) ///
 ///note("Note: 95% and 90% CIs shown", size(vsmall)) 
 scheme(plotplain)

 graph export "Figure5.png", replace

*** Appendix Table G7


local controls " responseorder"


 
 
 regress partylike_index i.treat_stack_v2 i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
 by U0, sort: gen nvals = _n  if e(sample)&treat_stack_v2==0
 by U0, sort: replace nvals = nvals[_N]  if e(sample)&treat_stack_v2==0
 tab nvals
 drop nvals
estimates store m1
regress partylike i.treat_stack_v2 i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m1_like
regress partysocdist i.treat_stack_v2 i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m1_socdist
 
regress partylike_index i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m2a
regress partylike i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m2a_like
regress partysocdist i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m2a_socdist
regress partylike_index i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m2b
regress partylike i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m2b_like
regress partysocdist i.treat_stack_v2##i.party  `controls' if (idvotecat==2|idvotecat==4|lrself<=4)&treat3!=1&treat3!=3&party!=2&idvotecat!=1&idvotecat!=3, cluster(U0)
estimates store m2b_socdist


 esttab m1 m1_like m1_socdist m2a m2a_like m2a_socdist  using "AppendixTableG7.tex", b(%6.3f) se(%6.3f) starlevels(* .05 ** .01 *** .001)  scalars (r2) legend alignment(D{.}{.}{-1})  label varlabels(_cons Constant)  eqlabels(none) title(Overall results (Fig 5) \label{Fig5}) replace
 
 
 log close